app.controller("queueMonitorCtrl", function ($scope, queueMonitorService, $timeout) {
    var msgBox = null;
    function getQueueInfo () {
        queueMonitorService.getQueueMonitor({
            action: 'getQueueInfo'
        }, function (data) {
            if (data.state == 'SUCCESS') {
                $scope.queueInfoList = data.data.queueInfoVO;
            } else {
                if(msgBox == null) {
                    msgBox = message_alert('提示',data.reason, function() {
                        msgBox == null
                    });
                }
            }
        });
        $timeout(function () {
            getQueueInfo();
        }, $scope.selectTime);
    };
    getQueueInfo();
    $scope.changeTime = function (time) {
        $scope.selectTime=time;
    };
    $scope.showDialogQueueInfo = function (queueInfo) {

        $('#dialogQueueInfo').on('show.bs.modal', function () {
            $scope.queueName =queueInfo.name;
            $scope.queueDepth =queueInfo.depth;
        });
        $("#dialogQueueInfo").modal('show');
    };
    $scope.clearQueue = function(){
        queueMonitorService.clearQueue({
            action:'clearQueue',
            queueName:$scope.queueName
        },function(data){
            if (data.state == 'SUCCESS') {
                $("#dialogQueueInfo").modal("hide");
                message_alert('提示','清空队列成功',function(){
                    getQueueInfo();
                });
            } else {
                if(msgBox == null) {
                    msgBox = message_alert('提示',data.reason, function() {
                        msgBox == null
                    });
                }
            }
        });
    }
});
